import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  },
  server: {
  proxy: {
    '/api': {
      target: 'http://127.0.0.1:5000',
      changeOrigin: true,  // 必须为 true
      rewrite: (path) => path.replace(/^\/api/, ''), // 确保路径正确
      // 可选：增加超时设置（Vite 默认无超时限制）
      configure: (proxy, options) => {
        proxy.on('proxyReq', (proxyReq) => {
          proxyReq.setHeader('Connection', 'keep-alive');
        });
      }
    }
  }
}
})